﻿using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands
{
    public record UserSignInCommand(string UserName, string Password) : IRequest<SignInResultModel>;

    public class UserSignInCommandHandler : IRequestHandler<UserSignInCommand, SignInResultModel>
    {
        private readonly IUserAccountService _service;
        public UserSignInCommandHandler(IUserAccountService service) => _service = service;

        public async Task<SignInResultModel> Handle(UserSignInCommand request, CancellationToken cancellationToken)
        {
            return await _service.SignInAsync(request.UserName, request.Password);
        }
    }
}
